package com.cloudcc.mobile.bull.utils;

import android.app.Activity;
import android.app.Dialog;
import android.support.v7.app.AlertDialog;
import android.view.Display;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;

import com.cloudcc.mobile.R;

/**
 * Created by yaojiping on 2017/12/8.
 */

public class DiaUtils {

    public static void cameraPick(Activity context, final Res2 res){
        AlertDialog.Builder builder=new AlertDialog.Builder(context, R.style.MyDialogTheme);
        View views= LayoutInflater.from(context).inflate(R.layout.camera_item,null);
        builder.setView(views);
        final Dialog dialog=builder.create();
        views.findViewById(R.id.tv1).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                res.res(1);
                dialog.dismiss();
            }
        });
        views.findViewById(R.id.tv2).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                res.res(2);
                dialog.dismiss();
            }
        });
        views.findViewById(R.id.tv_cancle).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dialog.dismiss();
            }
        });
        dialog.show();
        Window dialogWindow = dialog.getWindow();
        dialogWindow.setGravity(Gravity.BOTTOM);
        WindowManager windowManager =context.getWindowManager();
        Display display = windowManager.getDefaultDisplay();
        WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
        lp.width = (int) (display.getWidth()); //设置宽度
        dialogWindow.setAttributes(lp);
    }
    public interface Res2{
        public void res(int i);
    }
}
